class Solution {
public:
    int jump(vector<int>& nums) {
      int p = 0;
      int q = 0;
      int cnt = 0;
      if(nums.size() <= 1){
        return 0;
      }
      for(int i = 0;i < nums.size() - 1;i++){
        p = max(p,i + nums[i]);
        if(i == q){
          cnt++;
          q = p;
        }
      }
      return cnt;
    }
};
